import { request } from "@/utils/http";
import {
  getHospitalSearchParamsType,
  getHospitalListType,
  getProvinceType,
  getHospitalDetailType,
  getHospitalDepartmentListType,
  getHospitalScheduleRuleParamsType,
  getHospitalScheduleRuleListType,
  getHospitalScheduleAndDetailParamsType,
  getHospitalScheduleAndDetailListType,
} from "./model/hospitalListType";

// 1、 医院列表获取完整数据
export const getHospitalListRequest = (
  page: number,
  limit: number,
  searchParams: getHospitalSearchParamsType
) => {
  return request.get<any, getHospitalListType>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: searchParams,
    }
  );
};

// 2、获取所有的省份
export const getProvinceRequest = () => {
  return request.get<any, getProvinceType>(
    "/admin/cmn/dict/findByDictCode/province"
  );
};

// 3.获取所有的市或县区
export const getCityOrDistrictRequest = (value: string) => {
  return request.get<any, getProvinceType>(
    `/admin/cmn/dict/findByParentId/${value}`
  );
};

// 4.获取医院详情页
export const getHospitalDetailRequest = (id: string) => {
  return request.get<any, getHospitalDetailType>(
    `/admin/hosp/hospital/show/${id}`
  );
};

// 5.更新上下线状态
export const getHospitalStatusRequest = (id: string, status: 0 | 1) => {
  // console.log(id, status);
  return request.get(`/admin/hosp/hospital/updateStatus/${id}/${status}`);
};

//6.医院排版科室数据请求
export const getHospitalDepartmentRequest = (hoscode: string) => {
  return request.get<any, getHospitalDepartmentListType>(
    `/admin/hosp/department/${hoscode}`
  );
};

//7.医院排班规则数据请求
export const getHospitalScheduleRuleRequest = ({
  page,
  limit,
  hoscode,
  depcode,
}: getHospitalScheduleRuleParamsType) => {
  return request.get<any, getHospitalScheduleRuleListType>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
};

// 8.医院排班日期和详情请求
export const getHospitalScheduleAndDetailRequest = ({
  hoscode,
  depcode,
  workDate,
}: getHospitalScheduleAndDetailParamsType) => {
  return request.get<any, getHospitalScheduleAndDetailListType>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
};
